package com.parsechina.hpush.rest.base.web;

/**
 * @author linfeng
 * @date 2019-08-23
 **/
public class View<T> {

    private Integer code;
    private String message;
    private T data;

    public View(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> View<T> ofOk(T data) {
        return new View<>(200, "OK", data);
    }

    public static <T> View<T> ofError(String message) {
        return new View<>(500, message, null);
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public T getData() {
        return data;
    }
}
